

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import constants.AirlineReservationServiceConstants;

import service.AirlineReservationServiceProxy;

/**
 * Servlet implementation class updateFlightsServlet
 */
public class updateFlightsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		
		long flightId = Long.parseLong(req.getParameter("id"));
		String flightNumber =  req.getParameter("flightNumber").trim();
		String airlineName  =  req.getParameter("airlineName").trim();
		String source  =  req.getParameter("source").trim();
		String destination  =  req.getParameter("destination").trim();
		int numSeats  =  Integer.parseInt(req.getParameter("numSeats"));
		String pilotName  =  req.getParameter("pilotName").trim();
		String intermediate  =  req.getParameter("intermediate").trim();
		String intermediateArrivalTime  =  req.getParameter("intermediateArrivalTime").trim();
		String intermediateDepartureTime  =  req.getParameter("intermediateDepartureTime").trim();
		String timeOfFlight  =  req.getParameter("timeOfFlight").trim();
		Double ticketPrice = Double.parseDouble(req.getParameter("ticketPrice"));
		String status= req.getParameter("status").trim();
		
	
		
		proxy.changeFlightInfo(flightNumber,airlineName,source,destination,numSeats,pilotName,intermediate,intermediateArrivalTime,intermediateDepartureTime,timeOfFlight, ticketPrice, status, flightId);
		
		req.setAttribute("editFlightSucsess", "Edit Flight Success");
		req.getRequestDispatcher("viewAllFlights.do").forward(req,resp);

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
	doGet(req, resp);
	}


}
